package cc.yugu.yhdw.common.domain.basic;

import cc.yugu.yhdw.common.domain.IntIdEntity;
import org.apache.commons.lang.StringUtils;

/**
 * 短信模板实体类
 * 
 * @Date:Created in 2018/7/25 14:08
 * @Author:
 * @Modified By: zjn 2018/7/25 14:08
 */ 
public class MobileMessageTemplate extends IntIdEntity {

    public static final int DEFAULT_AGENT_ID = 0;

    public enum Type {
        AUTH_CODE(1),
        NEW_DEPOSIT(2),
        ;

        private final int value;

        private Type(int value) {
            this.value = value;
        }

        public int getValue() {
            return value;
        }
    }

    Integer agentId;
    String title; //标题
    String content; //内容
    String receiver; //接收者
    String variable; //变量
    String code; //编码

    public String replace(String... param) {
        if(param.length % 2 != 0) {
            throw new IllegalArgumentException();
        }

        String copy = content;
        for(int i = 0; i < param.length; i = i + 2) {
            copy = StringUtils.replace(copy, "${" + param[i] + "}", StringUtils.trimToEmpty(param[i + 1]));
        }
        return copy;
    }

    public Integer getAgentId() {
        return agentId;
    }

    public void setAgentId(Integer agentId) {
        this.agentId = agentId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getReceiver() {
        return receiver;
    }

    public void setReceiver(String receiver) {
        this.receiver = receiver;
    }

    public String getVariable() {
        return variable;
    }

    public void setVariable(String variable) {
        this.variable = variable;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
}
